<?php
	####################################################
	# library import and object instance.              #
	####################################################
	include_once('./common.php');


	####################################################
	# request data($_POST AND $_GET FROM $_REQUEST)    #
	####################################################
	# REQUEST(get and post variables)
	$req = Request::clean_request($_REQUEST, TRUE);

	# GET(url variables)

	# POST(form variables)

	# Validation(special case validate)
	//*/
	Validation::check_is_emptys($req);
	Validation::check_is_email($req['memail']);
	Validation::check_is_phone($req['mphone']);

	//Nlog::xmp($req); //display clean and remmap values
	//*/
	####################################################
	# implementation                                   #
	####################################################
	//*/
	#입력한 비밀번호 정보 일치 확인
	$ret = $db->get(
		sprintf("SELECT * FROM `n_member` WHERE `muid`='%s' AND `mpasswd`='%s'",
			$sess['res']['session_val']['muid'],
			$req['mpasswd']
		)
	);
	//Nlog::xmp($sess['res']['session_val']['muid']);
	//Nlog::xmp($req['mpasswd']);
	if($ret['has']){
		# 업데이트 한다.
		$retupt = $db->query(
			sprintf("UPDATE `n_member` SET `memail`='%s',`mphone`='%s',`mjob`='%s',`msex`='%s',`mmsg`='%s' WHERE `muid`='%s';",
				$req['memail'],
				$req['mphone'],
				$req['mjob'],
				$req['msex'],
				$req['mmsg'],
				$sess['res']['session_val']['muid']
			)
		);
	}
	//Nlog::xmp($ret);
	//*/

?>
<?php
	$html->custom_header(TITLE);
	$html->custom_js("{$JS}jquery.1.7.1.min.js");
	$html->custom_js("{$JS}lib.control.js");
	$html->custom_css("{$CSS}basic.css");
?>
<?$html->custom_body();?>
<?=$tmp->tiles_header()?>
	<h1>회원정보</h1>
	<?php if($retupt): ?>
		회원정보 변경에 성공 하였습니다.
	<?php else: ?>
		회원정보 변경에 실패 하였습니다. 입력한 패스워드가 일치 하지 않습니다.
	<?php endif; ?>
	<?=NTool::btn("뒤로", "Mover.back();");?>
	<?=NTool::btn("인덱스", "Mover.home();");?>
<?=$tmp->tiles_footer()?>
<?php $html->html_footer(); ?>